package cate.game.play.buff.h;

import cate.game.play.buff.BuffHandler;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import easy.java.struct.ref.DoubleRef;

/**
 * 且生命值无法超过当前生命值的100%
 */
public class 凋零BH extends BuffHandler {

	private double 最大系数;

	//最大系数=10000
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		最大系数 = args.getWDouble("最大系数", 0d);
	}


	private double hpMax;

	@Override
	public void onAdd(ActionCtx action) {
		hpMax = buff.owner.attr.hpCur()*最大系数;
	}

	@Override
	public void adjustHeal(ActionCtx action, Fighter actor, DoubleRef doubleRef) {
		double allowHeal = hpMax - buff.owner.attr.total().hpCur();
		if (doubleRef.v > allowHeal) {
			doubleRef.v = allowHeal;
		}
	}
}
